import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  // 一级路由
  { path: '/login', component: () => import('@/views/Login') },
  {
    path: '/',
    redirect: '/dashboard' /* 重定向配置页面 */,
    component: () => import('@/views/Home'),
    children: [
      /* 嵌套路由 */
      { path: 'dashboard', component: () => import('@/views/Home/Dashboard') },
      {
        path: 'user',
        component: () => import('@/views/Home/User'),
      },
      {
        path: 'user/useradd',
        component: () => import('@/views/Home/User/UserAdd'),
      },
      { path: 'category', component: () => import('@/views/Home/Category') },
      { path: 'Blog', component: () => import('@/views/Home/Blog') },
    ],
  },
  { path: '*', component: () => import('@/views/404') } /* 404页面设置 */,
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
})

export default router
